package Class.Homemade.demo0525.demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 姚东名
 * Date: 2024-05-25
 * Time: 20:52
 */
public class Test {
    public static void drawMap(Shape shape) {
        shape.draw();
    }
    public static void main(String[] args) {
        //注意：抽象类不能实例化
        //Shape shape = new Shape();
        //但是可以向上转型
        Shape shape1 = new Rect();
        Shape shape2 = new Cycle();
        //传参
        drawMap(shape1);
        drawMap(shape2);
        System.out.println("=========");
        //也可以用匿名对象，但是只能用一次：
        drawMap(new Cycle());
        drawMap(new Rect());
        System.out.println("=========");
        new Rect().draw();
        new Cycle().draw();
    }
}
